package com.misty.auth.config;

import com.alibaba.fastjson.JSON;
import com.misty.common.bean.Result;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@Deprecated
@Component
public class MyAuthenticationLogout implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        Result<?> result=Result.success(0,"注销成功！");
        httpServletResponse.setContentType("text/json;charset=utf-8");
        //返回给前台
        PrintWriter writer = httpServletResponse.getWriter();
        writer.write((char[]) JSON.toJSON(result));
        writer.flush();
        writer.close();
    }
}
